package com.example.gfsquadwebviewproject.input;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.gfsquadwebviewproject.R;

public class InputPwdNumberAdapter extends BaseAdapter {

    private String array[] = {"1","2","3","4","5","6","7","8","9","取消","0","删除"};
    private Context mContext;

    public InputPwdNumberAdapter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return array.length;
    }

    @Override
    public String getItem(int position) {
        return String.valueOf(array[position]);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ItemHolder itemHolder;
        if (convertView == null) {
            itemHolder = new ItemHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.input_view_item, null);

            itemHolder.mNumberTextView = convertView.findViewById(R.id.number_textView);
            convertView.setTag(itemHolder);
        } else {
            itemHolder = (ItemHolder) convertView.getTag();
        }

        String curNumber = getItem(position);

        itemHolder.mNumberTextView.setText(curNumber);

        return convertView;
    }

    private static class ItemHolder {

        TextView mNumberTextView;
    }

}
